import type { JobLog } from "@/pages/tool/job/entity";
import apiClient from "../../apiClient";

export interface PageListReq {
  jobId?: React.Key,
  //任务名称
  jobName?: string;
  //任务组名
  jobGroup?: string;
  //调用目标字符串
  invokeTarget?: string;
  //执行状态（0正常 1失败）
  status?: string;
  //当前页码
  page: number;
  //每页数量
  pageSize: number;
}

export interface PageListRes {
  //总记录数
  total: number;
  //数据列表
  records: JobLog[];
}

const pageList = (data: PageListReq): Promise<PageListRes> =>
  apiClient.post({
    url: "/tool/jobLog/pageList",
    data
});

const getInfo = (id: React.Key): Promise<JobLog> =>
  apiClient.get({
    url: `/tool/jobLog/${id}`
});

const add = (data: JobLog): Promise<JobLog> =>
  apiClient.post({
    url: "/tool/jobLog",
    data
});

const update = (data: JobLog): Promise<JobLog> =>
  apiClient.put({
    url: "/tool/jobLog",
    data
});

const remove = (ids: React.Key[]): Promise<void> =>
  apiClient.delete({
    url: "/tool/jobLog",
    params: {
    ids: ids.join(",")
  }
});

export const jobLogService = {
  pageList,
  getInfo,
  add,
  update,
  remove
};

export default jobLogService;